﻿<%@ Page Title="Comandas" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="comandas.aspx.cs" Inherits="Restaurante.comandas" %>

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
         <p id="titulo"> Comandas </p>
    </h2>
    <br />
    <div id="usuleft" Class="contTabla" style="width: 350px;
float: left;">  
    <table>
        <tr>
            <td>
                <asp:Label ID="Label3" runat="server" Text="Mesa:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtMesa" runat="server" Enabled="False"></asp:TextBox>
                <asp:TextBox
                    ID="txbNroComanda" runat="server" Visible="False"></asp:TextBox>
                
         <!--       <asp:DropDownList ID="ddlMesa" runat="server" DataSourceID="mesasComanda" 
                    DataTextField="Descripcion" DataValueField="Nro_Comanda">
                </asp:DropDownList>
                <asp:SqlDataSource ID="mesasComanda" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" SelectCommand=" select c.Nro_Comanda, m.Descripcion
  from Comanda c,
       Mesa m
 where c.Id_Mesa = m.Id_Mesa 
 union all
 select  0, 'Sin Seleccionar'  
 order by 1"></asp:SqlDataSource> -->
            </td>
         </tr>
   
         <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="Mozo:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlMozoComanda" runat="server" DataSourceID="mozos" 
                    DataTextField="nombre" DataValueField="id_usuario" AutoPostBack="True">
                </asp:DropDownList>
              
                <asp:SqlDataSource ID="mozos" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" SelectCommand="select u.id_usuario, u.nombre
from Usuario u,
	rol r
where u.Id_Rol = r.Id_Rol
and r.descripcion = 'Mozo'"></asp:SqlDataSource>
              
            </td>
        </tr>



        <tr>
            <td>
                <asp:Label ID="lblMenu" runat="server" Text="Menu:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlMenuPre" runat="server" DataSourceID="MenusGrillas" 
                    DataTextField="Descripcion" DataValueField="Id_MenuPrecargado">
                </asp:DropDownList>
                <asp:SqlDataSource ID="MenusGrillas" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" SelectCommand=" SELECT mp.Id_MenuPrecargado,
	    mp.Descripcion +': '+p.Descripcion+', '+b.Descripcion Descripcion
 FROM Menu_Precargado mp,
	  Bebida b,
	  Plato p
where b.Id_Bebida = mp.Id_Bebida
 and p.Id_Plato = mp.Id_Plato
union all
select 0, 'Sin Seleccionar'
order by 1 "></asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label5" runat="server" Text="Cantidad Menus:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txbCantMenu" runat="server"></asp:TextBox>

            </td>
        </tr>

        <tr>
            <td>
                <asp:Label ID="lblPlato" runat="server" Text="Plato:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlPlato" runat="server" DataSourceID="Platos" 
                    DataTextField="descripcion" DataValueField="Id_Plato">
                </asp:DropDownList>
                <asp:SqlDataSource ID="Platos" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
                    SelectCommand="SELECT Id_Plato, descripcion FROM Plato
union all
select 0, 'Sin Seleccionar'
order by 1">
                </asp:SqlDataSource>
            </td>
        </tr>
         <tr>
            <td>
                <asp:Label ID="Label6" runat="server" Text="Cantidad Plato:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txbCantPlato" runat="server"></asp:TextBox>

            </td>
        </tr>

        <tr>
            <td>
                <asp:Label ID="lblBebida" runat="server" Text="Bebida:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlBebida" runat="server" DataSourceID="Bebidas" 
                    DataTextField="Descripcion" DataValueField="Id_Bebida">
                </asp:DropDownList>
                <asp:SqlDataSource ID="Bebidas" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
                    SelectCommand="SELECT Id_Bebida, Descripcion FROM Bebida
union all
select 0, 'Sin Seleccionar'
order by 1">
                </asp:SqlDataSource>
            </td>
        </tr>
         <tr>
            <td>
                <asp:Label ID="Label7" runat="server" Text="Cantidad Bebida:"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txbCanBebida" runat="server"></asp:TextBox>

            </td>
        </tr>

         <tr>
            <td>
                <asp:Label ID="Label2" runat="server" Text="Estado:"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="ddlEstado" runat="server" DataSourceID="Estados" 
                    DataTextField="Descripcion" DataValueField="Id_Estado">
                </asp:DropDownList>
                <asp:SqlDataSource ID="Estados" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
                    ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
                    
                    SelectCommand="SELECT [Id_Estado], [Descripcion], [Clave] FROM [Estado] WHERE ([Clave] = @Clave) ORDER BY [Id_Estado]">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="Cocina" Name="Clave" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>

        
    </table>
    
    <br />
    <br />
    <asp:Button ID="btnCerrarMesa" runat="server" Text="Cerrar Mesa" 
            onclick="btnCerrarMesa_Click"/> 
    <asp:Button ID="btnAgregar" runat="server" Text="Aceptar" 
            onclick="btnAgregar_Click"/>
    <asp:Button ID="btnCancelar" runat="server" Text="Cancelar" 
        onclick="btnCancelar_Click"/>
        </div>

<div>
    comandas por mozo
    <asp:GridView ID="gvComandas" runat="server" CellPadding="4" 
        DataSourceID="ComandasAgrupada" ForeColor="#333333" GridLines="None" 
        AutoGenerateColumns="False" DataKeyNames="comanda" AllowPaging="True" 
        AllowSorting="True" 
        onselectedindexchanged="gvComandas_SelectedIndexChanged">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="comanda" HeaderText="comanda" 
                InsertVisible="False" ReadOnly="True" SortExpression="comanda" />
            <asp:BoundField DataField="cliente" HeaderText="cliente" 
                SortExpression="cliente" ReadOnly="True" />
            <asp:BoundField DataField="mesa" HeaderText="mesa" 
                SortExpression="mesa" />
            <asp:BoundField DataField="sector" HeaderText="sector" 
                SortExpression="sector" />
            <asp:BoundField DataField="estaddo" HeaderText="estaddo" 
                SortExpression="estaddo" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <asp:SqlDataSource ID="ComandasAgrupada" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
        ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
        
        SelectCommand=" SELECT c.Nro_Comanda comanda, cl.Nombre +' ' +cl.Apellido cliente , m.Descripcion mesa,  s.Descripcion sector, e.Descripcion estaddo
  FROM Comanda c,
       cliente cl,
	   Estado e,
	   Mesa m,
	   Sector s
where cl.Id_Cliente = c.Id_Cliente
   and e.Id_Estado = c.Id_Estado
   and m.Id_Mesa = c.Id_Mesa
   and s.Id_Sector = m.Id_Sector
   and e.Id_Estado = 4">
    </asp:SqlDataSource>
</div>
   <div  class="contTabla" style="width: 340px;
float: left;">
        Detalle Domanda
       <asp:GridView ID="gvComndasDetalle"  runat="server"  CellPadding="4" 
            ForeColor="#333333" GridLines="None" Width="575px" 
            AutoGenerateColumns="False" ShowFooter="True" AllowPaging="True" 
           AllowSorting="True" 
            DataSourceID="ComandasDetalle">
            <AlternatingRowStyle BackColor="White"/>
            <Columns>                
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="plato" HeaderText="plato" 
                    SortExpression="plato" ReadOnly="True" />
                <asp:BoundField DataField="bebida" HeaderText="bebida" 
                    SortExpression="bebida" ReadOnly="True" />
                <asp:BoundField DataField="menu" HeaderText="menu" 
                    SortExpression="menu" ReadOnly="True" />
                <asp:BoundField DataField="bebida1" HeaderText="bebida1" ReadOnly="True" 
                    SortExpression="bebida1" />
                <asp:BoundField DataField="estado" HeaderText="estado" ReadOnly="True" 
                    SortExpression="estado" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
       </asp:GridView>
        <asp:SqlDataSource ID="ComandasDetalle" runat="server" 
            ConnectionString="<%$ ConnectionStrings:BarCafe %>" 
            ProviderName="<%$ ConnectionStrings:BarCafe.ProviderName %>" 
            SelectCommand="select 
		(select m.Descripcion 
		   from menues m
		   where cd.Menues_Id_Menu = m.Id_Menu
		 )plato,
		 (select b.Descripcion 
		   from menues m,
				Bebida b
		   where cd.Menues_Id_Menu = m.Id_Menu
			and b.Id_Bebida = m.Id_Bebida
		 )bebida,
		 (select mp.Descripcion 
		   from Menu_Precargado mp
		   where cd.Menu_Precargado_Id_MenuPrecargado = mp.Id_MenuPrecargado
		 )menu,
		 (select b.Descripcion 
		   from Menu_Precargado mp,
				Bebida b
		   where cd.Menu_Precargado_Id_MenuPrecargado = mp.Id_MenuPrecargado
			and b.Id_Bebida = mp.Id_Bebida
		 )bebida,
		 (select e.descripcion
			from estado e
			where e.id_estado = cd.Id_Estado
		 )estado
 from Comanda c, 
      Comanda_Detalle cd
where cd.Nro_Comanda = c.nro_comanda
       and cd.Id_Estado = 1"></asp:SqlDataSource>
   </div> 
   <br/>
    <asp:Label ID="lblError" runat="server" ForeColor="Red"></asp:Label>
</asp:Content>

